var app = getApp();
Page({

  data: {
    info:[],

    date: '',
    liyou:'',
    date2:'',
    choose:'',
    itemList: ['正常', '返工','报废'],
    status:'点击选择状态',
    userInfo: null,
    title:'',
    buttom:'',
    zhicheng:'',
    
  },

  

  onLoad: function (options) {
    var that = this
    var date = new Date();

    var jintian = date.getDate()
    var mingtian = date.getDate()+1

    var todate = date.getFullYear() + "-" + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth()+1) + "-" + (jintian < 10 ? ("0" + jintian) : jintian);
    var todate2 = date.getFullYear() + "-" + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth()+1) + "-" + (mingtian < 10 ? ("0" + mingtian) : mingtian);
    
    that.setData({ date: todate});
    that.setData({ date2: todate2});

  },
  onShow:function(){
    this.getlist()
  },


  godetail: function(e) {
        wx.navigateTo({
          url: '/page/my/qingjiaodetail?id='+e.currentTarget.dataset.fee,
        });
  },

  bindDateChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
    this.getlist()
  },


  bindDateChange2: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date2: e.detail.value
    })
    this.getlist()
  },

  getlist:function (){
    // var lid = 1
  
    var that = this

    wx.request({
      url: app.apiUrl + '/api/index/getqingjialist',
      data: {
        openid:wx.getStorageSync('openid'),
        groupid:wx.getStorageSync('groupid'),
        // sdate:that.data.date,
        // edate:that.data.date2,
      },
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
      success: function (res) {
        if(res.data.code == 1){
          that.setData({ info: res.data.data});
            
        }else{
          wx.showModal({
            title: '温馨提示',
               content: res.data.msg,
                 showCancel: false
            });

            that.setData({ info: ''});
        }
     
      }
    });
  },


  tongguo:function (e){
    var that = this
    wx.request({
      url: app.apiUrl + '/api/index/qingjiatongguo',
      data: {
        openid:wx.getStorageSync('openid'),
        groupid:wx.getStorageSync('groupid'),
        qid:e.currentTarget.dataset.fee,
        stutus:1

      },
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
      success: function (res) {
        wx.showModal({
          title: '温馨提示',
          content: res.data.msg,
          showCancel: false
        });
        that.getlist()
        // setTimeout(function () {
        //   wx.navigateTo({
        //     url: '/page/my/index',
        //   });
        // }, 2000)
      }
    });
  },



  jujue:function (e){
    var that = this
    wx.request({
      url: app.apiUrl + '/api/index/qingjiajujue',
      data: {
        openid:wx.getStorageSync('openid'),
        groupid:wx.getStorageSync('groupid'),
        qid:e.currentTarget.dataset.fee,
        stutus:2
      },
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
      success: function (res) {
        wx.showModal({
          title: '温馨提示',
          content: res.data.msg,
          showCancel: false
        });
        that.getlist()
        // setTimeout(function () {
        //   wx.navigateTo({
        //     url: '/page/my/index',
        //   });
        // }, 2000)
      }
    });
  },


})